package com.cn.web.bean;

import cn.com.allunion.common.page.QueryResult;
import cn.com.allunion.sms.pojo.Smsoperator;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 运营商返回结果
 * Created by YangJie on 2016/4/20.
 */
public class OperatorResult {
    @JSONField(name="operatorId")
    private String smsOperatorID;

    @JSONField(name="operatorCode")
    private String joinNum;

    @JSONField(name="status")
    private String joinState;

    @JSONField(name="operatorName")
    private String smsOperatorName;

    /**
     * 将Smsoperator集合转换为SmsoperatorResult集合
     * @param smsoperators 待转换的集合对象
     * @return 转换后的结果
     */
    public static List<OperatorResult> convert(List<Smsoperator> smsoperators) {
        if (null == smsoperators) {
            return null ;
        }
        List<OperatorResult> smsoperatorResults = new ArrayList<>(smsoperators.size()) ;
        OperatorResult result ;
        for (Smsoperator so : smsoperators) {
            result = new OperatorResult() ;
            BeanUtils.copyProperties(so, result);
            smsoperatorResults.add(result);
        }

        return smsoperatorResults ;
    }

    /**
     * 将queryResult分解结果集合转换为SmsoperatorResult分页结果集合
     * @param queryResult 待转换的分页集合对象
     * @return 转换后的结果
     */
    public static QueryResult<OperatorResult> convert(QueryResult<Smsoperator> queryResult) {
        if (null == queryResult) {
            return null ;
        }
        return new QueryResult<OperatorResult>(convert(queryResult.getResultList()), queryResult.getTotalRecord()) ;
    }

    /**
     * 将Smsoperator对象转换为SmsoperatorResult
     * @param smsoperator 要转换的对象
     * @return 转换后的对象
     */
    public static OperatorResult convert(Smsoperator smsoperator) {
        if (null == smsoperator) {
            return null;
        }
        OperatorResult result = new OperatorResult() ;
        BeanUtils.copyProperties(smsoperator, result);

        return result ;
    }

    public String getSmsOperatorID() {
        return smsOperatorID;
    }

    public void setSmsOperatorID(String smsOperatorID) {
        this.smsOperatorID = smsOperatorID;
    }

    public String getJoinNum() {
        return joinNum;
    }

    public void setJoinNum(String joinNum) {
        this.joinNum = joinNum;
    }

    public String getJoinState() {
        return joinState;
    }

    public void setJoinState(String joinState) {
        this.joinState = joinState;
    }

    public String getSmsOperatorName() {
        return smsOperatorName;
    }

    public void setSmsOperatorName(String smsOperatorName) {
        this.smsOperatorName = smsOperatorName;
    }
}
